﻿using System;
using TheLocal.Common;
using System.ComponentModel;

namespace TheLocal.Model
{
    public class NewsItem : INotifyPropertyChanged
    {
        private string content;

        public event PropertyChangedEventHandler PropertyChanged;

        public NewsItem()
        {

        }

        public void ResolveFullImagePath(Country country)
        {
            this.FullImagePath = string.Format("{0}{1}/{2}", Constants.WebsiteHost, country.Code, ImagePath);
        }

        public string Title { get; set; }

        public string ArticlePath { get; set; }

        public string ImagePath { get; set; }

        public string Description { get; set; }

        private string fullImagePath;

        public string FullImagePath
        {
            get
            {
                return fullImagePath;
            }
            private set
            {
                if (fullImagePath != value)
                {
                    this.fullImagePath = value;
                }
            }
        }

        public string Content
        {
            get
            {
                return content;
            }
            set
            {
                content = value;
                OnPropertyChanged("Content");
            }
        }

        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}
